package com.syx.system.Controller.question;


import com.syx.commoncore.Model.Result;
import com.syx.commoncore.Model.TableDataInfoResult;
import com.syx.system.Model.question.DTO.QuestionAddDTO;
import com.syx.system.Model.question.DTO.QuestionEditDTO;
import com.syx.system.Model.question.DTO.QuestionQueryDTO;
import com.syx.system.Model.question.VO.QuestionDetailVO;
import com.syx.system.Model.question.VO.QuestionQueryVO;
import com.syx.system.Service.IQuestionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/question")
@Tag(name = "题目管理接口")
public class QuestionController {


    @Resource
    IQuestionService iQuestionService;

    @GetMapping("/list")
    public TableDataInfoResult list(QuestionQueryDTO questionQueryDTO){



        return iQuestionService.list(questionQueryDTO);


    }
    //添加题目
    @PostMapping("/add")
    public Result<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return iQuestionService.add(questionAddDTO);



    }

    //点击编辑时返回相关页面
    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId){
        return iQuestionService.detail(questionId);

    }

    //编辑代码逻辑
    @PostMapping("/edit")
    public Result<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
        return iQuestionService.edit(questionEditDTO);


    }
    //删除题目信息
    @DeleteMapping("/delete")
    public Result<Void> delete(Long questionId){
        //return iQuestionService.delete(questionId);
        return iQuestionService.deleteQuestion(questionId);
    }


}
